(defun C:FIT ()
  (setvar "cmdecho" 0)
  (initget "ON OFf Defult Text Set")
  (setq ansr (getkword
    "\nON/OFF/Defult/Text(s)/<Set>:"))
  (cond
    ((= ansr "ON") (setvar "useri2" 1))
    ((= ansr "OFf")
        (progn
           (setvar "useri2" 0)
           (setq p1 (cons x1 (cddr (assoc 10 (entget (entlast))))))
           (setq p1 (cons x1 (cdr p1)))
           (setvar "userr1" (car p1) )
           (setvar "userr2" (cadr p1) )
           (setvar "userr3"  x1 )
           (setvar "userr4"  x2 )
        )
    )
    ((= ansr "Defult")
      (progn
         (setvar "useri2" 1)
         (setq x1 180 x2 20)
         (setq p1 (cons x1 (cddr (assoc 10 (entget (entlast))))))
         (setq p1 (cons x1 (cdr p1)))
         (setvar "userr1" (car p1) )
         (setvar "userr2" (cadr p1) )
         (setvar "userr3"  x1 )
         (setvar "userr4"  x2 )
      )
    )
    ((= ansr "Text")
      (progn
        (setq x1t (rtos x1 2 1) x2t (rtos x2 2 1))
        (princ (strcat "\nSelect text(s) to fit between x=" x1t " and x=" x2t
                       " :"))
        (verifylock )
        (setq names (list "TEXT")
              texts "TEXT" )
        (verify ssobj names texts)
        (fittext ssobj)
        (print ssl)
        (princ (strcat (strcase texts T) "(s) fitted ."))
      )
    )
    ((or (= ansr "Set" ) (= ansr nil))
      (progn
        (initget "Line Text Points" )
        (princ "\n Get alignment points:")
        (setq ansr1 (getkword "\nLine/Text/<Points>:"))
        (cond
          ((= ansr1 "Line")
              (progn
                (setq fl (entsel "\nSelect first line:"))
                 (if (= (cdr(assoc 0 (entget (car fl)))) "LINE")
                  (progn
                   (setq x1 (cadr (assoc 10 (entget (car fl)))))
                   (setq sl (entsel "\nSelect second line:"))
                     (if (= (cdr(assoc 0 (entget (car sl)))) "LINE")
                      (progn
                       (setq x2 (cadr (assoc 10 (entget (car sl)))))
                       (setvar "useri2" 1)
                       (setq p1 (cons x1 (cddr (assoc 10 (entget (entlast))))))
                       (setq p1 (cons x1 (cdr p1)))
                       (setvar "userr1" (car p1) )
                       (setvar "userr2" (cadr p1) )
                       (setvar "userr3"  x1 )
                       (setvar "userr4"  x2 )
                      )
                      (progn
                            (princ "\n Entity isn't a LINE")
                            (exit)
                      )
                     )
                  )
                  (progn
                     (princ "\n Entity isn't a LINE")
                  )
                 )
              )
          )
          ((= ansr1 "Text")
              (progn
                (setq fl (entsel "\nSelect base text:"))
                 (cond
                  ((and
                      (=  (cdr(assoc 0  (entget (car fl)))) "TEXT")
                      (/= (cdr(assoc 41 (entget (car fl)))) 1.0   )
                   )
                   (progn
                    (setq x1 (cadr (assoc 10 (entget (car fl)))))
                    (setq x2 (cadr (assoc 11 (entget (car fl)))))
                       (setvar "useri2" 1)
                       (setq p1 (cons x1 (cddr (assoc 10 (entget(entlast))))))
                       (setq p1 (cons x1 (cdr p1)))
                       (setvar "userr1" (car p1) )
                       (setvar "userr2" (cadr p1) )
                       (setvar "userr3"  x1 )
                       (setvar "userr4"  x2 )
                   )
                  )
                  (  (and
                        (= (cdr(assoc 0  (entget (car fl)))) "TEXT")
                        (= (cdr(assoc 41 (entget (car fl)))) 1.0   )
                     )
                      (progn
                            (princ "\nEntity isn't a fitted Text !")
                      )
                  )
                  (  (/= (cdr(assoc 0  (entget (car fl)))) "TEXT")
                      (progn
                            (princ "\n Entity isn't a TEXT")
                      )
                  )
                 )
              )
          )
          ((or (= ansr1 "Points") (= ansr1 nil))
              (progn
                (setq fp (getpoint "\n Select first point:  "))
                (setq sp (getpoint "\n Select second point:  "))
                 (if (and fp sp)
                      (progn
                       (setvar "useri2" 1)
                       (setq x1 (car fp) x2 (car sp))
                       (setq p1 (cons x1 (cddr (assoc 10 (entget (entlast))))))
                       (setq p1 (cons x1 (cdr p1)))
                       (setvar "userr1" (car p1) )
                       (setvar "userr2" (cadr p1) )
                       (setvar "userr3"  x1 )
                       (setvar "userr4"  x2 )
                      )
                      (progn
                         (princ "\n Nothing selected")
                         (exit)
                      )
                 )
              )
          )
        )
      )
    )
  )
 (setvar "cmdecho" 1)
 (princ "\n Good luck !")
 (prin1)
)
